
//修复tooltip问题
biAdhocNs.ToolTipPlus = function() {
	return {
		showToolTip : function() { // 修复展现tooltip问题
			if (this.anchor) {
				var showListeners = this.events['show'].listeners; // fix
				this.events['show'].listeners = [];
				this.showAt([-1000, -1000]);
				this.origConstrainPosition = this.constrainPosition;
				this.constrainPosition = false;
				this.anchor = this.origAnchor;
				this.events['show'].listeners = showListeners ;// fix
			}
			this.showAt(this.getTargetXY());
			if (this.anchor) {
				this.syncAnchor();
				this.anchorEl.show();
				this.constrainPosition = this.origConstrainPosition;
			} else {
				this.anchorEl.hide();
			}
		},
		unbindTarget : function() { // 去除tooltip目标绑定事件
			if (this.target) {
				var tg = Ext.get(this.target);
				this.mun(tg, 'mouseover', this.onTargetOver, this);
				this.mun(tg, 'mouseout', this.onTargetOut, this);
				this.mun(tg, 'mousemove', this.onMouseMove, this);
			}
			this.target = null;
	
			if (this.anchor) {
				this.anchorTarget = null;
			}
		},
		showAtCenter : function(){
			if (this.anchor) {
				var showListeners = this.events['show'].listeners; // fix
				this.events['show'].listeners = [];
				this.showAt([-1000, -1000]);
				this.origConstrainPosition = this.constrainPosition;
				this.constrainPosition = false;
				this.anchor = this.origAnchor;
				this.events['show'].listeners = showListeners ;// fix
			}
			var pos = [400,200];
			/*if(this.parentID){
				var bt = Ext.getCmp(this.parentID);
				var panel = bt.findParentByType('panel');
				if(panel){
					var xy = panel.getPosition();
					pos[0] = (panel.getWidth() - this.getWidth())/2 + xy[0];
				}
			}*/
			this.showAt(pos);
			if (this.anchor) {
				this.syncAnchor();
				this.anchorEl.show();
				this.constrainPosition = this.origConstrainPosition;
			} else {
				this.anchorEl.hide();
			}
		},
	    onRender : function(ct, position){
	        Ext.ToolTip.superclass.onRender.call(this, ct, position);
	        this.anchorCls = 'x-tip-anchor-' + this.getAnchorPosition();
	        this.anchorEl = this.el.createChild({
	            cls: this.anchorCls
	        });
	    }
	};
}();

/**
 * 根据窦飞翔的代码抽出执行AJAX同步调用的方法
 */
biAdhocNs.AJAX = function() {
	return {
		synchronizeRun : function(url, para) { // 同步运行
			function createXhrObject() {
				var http;
				var activeX = ['MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'];
				try {
					http = new XMLHttpRequest();
				} catch (e) {
					for (var i = 0; i < activeX.length; ++i) {
						try {
							http = new ActiveXObject(activeX[i]);
							break;
						} catch (e) {
							;
						}
					}
				} finally {
					return http;
				}
			};
			var conn = createXhrObject();
			if (para != null && para != '' && typeof(para) != 'undefined') {
				url = [url, '?', para].join('');
			}
			conn.open("GET", url, false);
			conn.send(null);
			if (conn.responseText != '') {
				var rs;
				try {
					rs = Ext.util.JSON.decode(conn.responseText);
				} catch (e) {
					return null;
				}
				return rs;
			} else {
				return null;
			}
		}
	};
}();